package com.security.Utils;

import cn.hutool.captcha.CaptchaUtil;
import cn.hutool.captcha.LineCaptcha;
import cn.hutool.captcha.generator.RandomGenerator;

/**
 * 验证码 工具类
 * 2020-3-31
 * gdy
 */
public class CaptchaUtils {

    /*页面登录 验证 key 值*/
    public static final String CAPTCHA_SESSION_KEY = "captcha";

    /*手机短信登录 验证 key 值*/
    public static final String CAPTCHA_MOBILE_KEY = "mobile_captcha";

    /*图片验证码 通用函数*/
    public static LineCaptcha PC_Captcha(){
        LineCaptcha lineCaptcha = CaptchaUtil.createLineCaptcha(116, 36,5,10);
        return lineCaptcha;
    }

    /*手机短信 纯数字 验证码 通用函数*/
    public static LineCaptcha MOBILE_Captcha(){
        LineCaptcha lineCaptcha = CaptchaUtil.createLineCaptcha(116, 36,5,10);
        RandomGenerator randomGenerator = new RandomGenerator("0123456789", 4);
        lineCaptcha.setGenerator(randomGenerator);
        lineCaptcha.createCode();
        return lineCaptcha;
    }




}
